﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Org.Apache.Cassandra.Thrift;
using Me.Prettyprint.Cassandra.Service;

namespace Me.Prettyprint.Cassandra.Connection.Client
{
    /// <summary>
    /// HClient defines the base operations hector connections need to implement.
    /// The way Hector's HConnectionManager works, it is responsible for getting
    /// a client from the host pool and releasing it back to the pool. This means
    /// it isn't like typical database drivers. With classic single host database
    /// servers, calling close would return the connection to the pool. If the
    /// database server isn't available, the application gets an exception. With
    /// Cassandra, HConnectionManager will try another host if there was a time
    /// out or connection issue.
    /// </summary>
    public interface HClient
    {
        /// <summary>
        /// The time this client was created
        /// </summary>
        /// <returns></returns>
        long CreatedTime
        {
            get;
        }
        Org.Apache.Cassandra.Thrift.Cassandra.Client GetCassandra();

        Org.Apache.Cassandra.Thrift.Cassandra.Client GetCassandra(string keyspaceNameArg);

        HClient Close();

        HClient Open();

        bool IsOpen();

        void StartToUse();

        long SinceLastUsed
        {
            get;
        }
        CassandraHost CassandraHost
        {
            get;
        }
        void SetAuthentication(Dictionary<string, string> credentials);

        bool AlreadyAuthenticated(Dictionary<string, string> credentials);

        void ClearAuthentication();
        long LastSuccessTime
        {
            get;
        }
        void UpdateLastSuccessTime();
    }
}
